/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package EntidadesBD;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ROCIO
 */
@Entity
@Table(name = "contrato", catalog = "secdux", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Contrato.findAll", query = "SELECT c FROM Contrato c"),
    @NamedQuery(name = "Contrato.findByNumContrato", query = "SELECT c FROM Contrato c WHERE c.numContrato = :numContrato"),
    @NamedQuery(name = "Contrato.findByEps", query = "SELECT c FROM Contrato c WHERE c.eps = :eps"),
    @NamedQuery(name = "Contrato.findByArp", query = "SELECT c FROM Contrato c WHERE c.arp = :arp"),
    @NamedQuery(name = "Contrato.findByAfp", query = "SELECT c FROM Contrato c WHERE c.afp = :afp"),
    @NamedQuery(name = "Contrato.findByCategoria", query = "SELECT c FROM Contrato c WHERE c.categoria = :categoria"),
    @NamedQuery(name = "Contrato.findByPeriodoAcademico", query = "SELECT c FROM Contrato c WHERE c.periodoAcademico = :periodoAcademico"),
    @NamedQuery(name = "Contrato.findByFechaRealizacionContrato", query = "SELECT c FROM Contrato c WHERE c.fechaRealizacionContrato = :fechaRealizacionContrato"),
    @NamedQuery(name = "Contrato.findByFechaInicioContrato", query = "SELECT c FROM Contrato c WHERE c.fechaInicioContrato = :fechaInicioContrato"),
    @NamedQuery(name = "Contrato.findByFechaTerminacionContrato", query = "SELECT c FROM Contrato c WHERE c.fechaTerminacionContrato = :fechaTerminacionContrato")})
public class Contrato implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "NumContrato", nullable = false)
    private Long numContrato;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Eps", nullable = false, length = 50)
    private String eps;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Arp", nullable = false, length = 50)
    private String arp;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Afp", nullable = false, length = 50)
    private String afp;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Categoria", nullable = false)
    private int categoria;
    @Basic(optional = false)
    @NotNull
    @Column(name = "PeriodoAcademico", nullable = false)
    private int periodoAcademico;
    @Basic(optional = false)
    @NotNull
    @Column(name = "FechaRealizacionContrato", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date fechaRealizacionContrato;
    @Basic(optional = false)
    @NotNull
    @Column(name = "FechaInicioContrato", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date fechaInicioContrato;
    @Basic(optional = false)
    @NotNull
    @Column(name = "FechaTerminacionContrato", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date fechaTerminacionContrato;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "numContrato")
    private List<Contratodemateria> contratodemateriaList;
    @JoinColumn(name = "RealizadorContrato", referencedColumnName = "User", nullable = false)
    @ManyToOne(optional = false)
    private Usuario realizadorContrato;
    @JoinColumn(name = "Cedula", referencedColumnName = "Cedula", nullable = false)
    @ManyToOne(optional = false)
    private Persona cedula;
    @JoinColumn(name = "Cargo", referencedColumnName = "idCargo", nullable = false)
    @ManyToOne(optional = false)
    private Cargo cargo;

    public Contrato() {
    }

    public Contrato(Long numContrato) {
        this.numContrato = numContrato;
    }

    public Contrato(Long numContrato, String eps, String arp, String afp, int categoria, int periodoAcademico, Date fechaRealizacionContrato, Date fechaInicioContrato, Date fechaTerminacionContrato) {
        this.numContrato = numContrato;
        this.eps = eps;
        this.arp = arp;
        this.afp = afp;
        this.categoria = categoria;
        this.periodoAcademico = periodoAcademico;
        this.fechaRealizacionContrato = fechaRealizacionContrato;
        this.fechaInicioContrato = fechaInicioContrato;
        this.fechaTerminacionContrato = fechaTerminacionContrato;
    }

    public Long getNumContrato() {
        return numContrato;
    }

    public void setNumContrato(Long numContrato) {
        this.numContrato = numContrato;
    }

    public String getEps() {
        return eps;
    }

    public void setEps(String eps) {
        this.eps = eps;
    }

    public String getArp() {
        return arp;
    }

    public void setArp(String arp) {
        this.arp = arp;
    }

    public String getAfp() {
        return afp;
    }

    public void setAfp(String afp) {
        this.afp = afp;
    }

    public int getCategoria() {
        return categoria;
    }

    public void setCategoria(int categoria) {
        this.categoria = categoria;
    }

    public int getPeriodoAcademico() {
        return periodoAcademico;
    }

    public void setPeriodoAcademico(int periodoAcademico) {
        this.periodoAcademico = periodoAcademico;
    }

    public Date getFechaRealizacionContrato() {
        return fechaRealizacionContrato;
    }

    public void setFechaRealizacionContrato(Date fechaRealizacionContrato) {
        this.fechaRealizacionContrato = fechaRealizacionContrato;
    }

    public Date getFechaInicioContrato() {
        return fechaInicioContrato;
    }

    public void setFechaInicioContrato(Date fechaInicioContrato) {
        this.fechaInicioContrato = fechaInicioContrato;
    }

    public Date getFechaTerminacionContrato() {
        return fechaTerminacionContrato;
    }

    public void setFechaTerminacionContrato(Date fechaTerminacionContrato) {
        this.fechaTerminacionContrato = fechaTerminacionContrato;
    }

    @XmlTransient
    public List<Contratodemateria> getContratodemateriaList() {
        return contratodemateriaList;
    }

    public void setContratodemateriaList(List<Contratodemateria> contratodemateriaList) {
        this.contratodemateriaList = contratodemateriaList;
    }

    public Usuario getRealizadorContrato() {
        return realizadorContrato;
    }

    public void setRealizadorContrato(Usuario realizadorContrato) {
        this.realizadorContrato = realizadorContrato;
    }

    public Persona getCedula() {
        return cedula;
    }

    public void setCedula(Persona cedula) {
        this.cedula = cedula;
    }

    public Cargo getCargo() {
        return cargo;
    }

    public void setCargo(Cargo cargo) {
        this.cargo = cargo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (numContrato != null ? numContrato.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Contrato)) {
            return false;
        }
        Contrato other = (Contrato) object;
        if ((this.numContrato == null && other.numContrato != null) || (this.numContrato != null && !this.numContrato.equals(other.numContrato))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "EntidadesBD.Contrato[ numContrato=" + numContrato + " ]";
    }
    
}
